package com.zero.system.service.Impl;

import com.zero.system.entity.Company;
import com.zero.system.entity.Order;
import com.zero.system.mapper.CompanyMapper;
import com.zero.system.mapper.OrderMapper;
import com.zero.system.service.CompanyService;
import com.zero.system.service.OrderService;
import com.zero.system.util.PageBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service
public class OrderServiceImpl implements OrderService {
    @Resource
    private OrderMapper orderMapper;

    @Override
    public PageBean<Order> queryPage(Map<String, Object> paramMap) {
        PageBean<Order> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));
        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<Order> datas = orderMapper.queryList(paramMap);
        pageBean.setDatas(datas);
        Integer totalsize = orderMapper.getCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public Integer getCount(Map<String, Object> paramMap) {
        return orderMapper.getCount(paramMap);
    }

    @Override
    public int add(Order order) {
        return orderMapper.add(order);
    }

    @Override
    public Order findById(Integer id) {
        return orderMapper.findById(id);
    }

    @Override
    public int delete(List<Integer> ids) {
        return orderMapper.delete(ids);
    }

    @Override
    public int update(Order order) {
        return orderMapper.update(order);
    }


    @Override
    public List<Order> findAll() {
        return orderMapper.findAll();
    }

    @Override
    public List<Order> findByCustomerId(int customerId) {
        return orderMapper.findByCustomerId(customerId);
    }

    @Override
    public int updateState(int id, int state) {
        return orderMapper.updateState(id,state);
    }
}
